<?php
namespace app\manage\model;

class SdkBill extends Base
{
    protected $insert = ['balance_time'];

    //生成账单时间
    public function getBalanceTimeAttr($value){
        return date('Y-m-d', $value);
    }
    public function setBalanceTimeAttr(){
        return time();
    }

    //寄件时间
    public function getSendTimeAttr($value){
        return $value ? date('Y-m-d', $value) : '';
    }
    public function setSendTimeAttr($value){
        return $value ? strtotime($value) : '';
    }

    //收款时间
    public function getReceiptTimeAttr($value){
        return $value ? date('Y-m-d', $value) : '';
    }

    //发票类型
    public function getInvoiceTypeAttr($value){
        $cpInvoiceType = config('cp_invoice_type');
        foreach ($cpInvoiceType as $k=>$v){
            if($v['type'] == $value){
                return $v['name'];
            }
        }
    }

    //状态
    public function getStatusAttr($value){
        $cpAuditStatus = config('sdk_audit_status');
        return $cpAuditStatus[$value];
    }

    //开始时间
    public function getStartTimeAttr($value){
        return date('Y-m-d', $value);
    }
    //结束时间
    public function getEndTimeAttr($value){
        return date('Y-m-d', $value);
    }

    //游戏名称
    public function getChannelNameAttr($value, $data){
        return model('ViewChannel')->where('channel_id',$data['channel_id'])->value('channel_name');
    }
}